package com.fanshe;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        // 获取class对象
        Class<?> c = Class.forName("com.fanshe.Student");
        // public Student(String name, int age, String address)
        Constructor<?> cons = c.getConstructor(String.class, int.class, String.class);
        Object obj = cons.newInstance("林青霞", 30, "西安");
        System.out.println(obj);
    }
}
